<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="news.bll.topic.*"%>
<%@ page import="news.bll.news.*"%>
<%@ page import="news.entity.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'do_deletetopic.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <%
    request.setCharacterEncoding("utf-8");
    int tid = Integer.parseInt(request.getParameter("tid"));
    TopicDaoImpl tdi = new TopicDaoImpl();
    NewsDaoImpl ndi = new NewsDaoImpl();
    List<News> topicnews = ndi.getTidNews(tid);
    if(topicnews.size()==0){
    	int result = tdi.deleteTopic(tid);
        if(result>0){
    		%>
    		<script>
    			alert("主题删除成功！");
    			window.location="admin.jsp";
    		</script>    		
    		<%
    	}else{
    		%>
    		<script>
    			alert("主题删除失败！");
    			window.location="topic_edit.jsp";
    		</script>    		
    		<%
    	}
    }else{
    	%>
		<script>
			alert("该主题下还有文章，不能删除！");
			window.location="topic_edit.jsp";
		</script>    		
		<%
    }
    %>
  </body>
</html>
